package com.git_taoxian_test1;

public class Student {
//    私有成员变量
    private String name;
    private String gender;
    private int age;

//    构造方法
    public Student() {
    }

    public Student(String name, String gender, int age) {
        this.name = name;
        this.gender = gender;
        this.age = age;
    }

//  getter setter方法

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        if (gender.equals("男")||gender.equals("女")){
            this.gender = gender;
        }else{
            throw new SexException("性别异常！");
        }
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age>=0 && age<200){
            this.age = age;
        }else{
            throw new AgeException("年龄异常！");
        }
    }
}
